package com.autoerp.dao.jdbc.administracao;

import java.sql.Connection;

import org.mentabean.BeanSession;

import com.autoerp.dao.administracao.UfDAO;
import com.autoerp.model.administracao.UfEntity;
import com.autoerp.model.administracao.UsuarioEntity;

public class UfDAOJdbc implements UfDAO {
	/** The session. */
	private BeanSession session;

	/** The conn. */
	private Connection conn;

	public UfDAOJdbc(BeanSession session) {
		this.session = session;
		this.conn = session.getConnection();
	}

	/**
	 * Localizar a UF atraves do seu identificador.
	 * 
	 * @param id_uf
	 *            the id_uf
	 * @return instancia da UF
	 */
	public UfEntity buscarPorId(Integer id_uf) {
		// Cria instancia da UF
		UfEntity uf = new UfEntity();
		// Seta identificador da uf
		uf.setId_uf(id_uf);

		// Busca e retorna UF
		if (session.load(uf)) {
			return uf;
		}

		// Retorna null se a UF nao for encontrada
		return null;
	}

}
